<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>广告位管理</title>
</head>
<body>
<div layout:fragment="content">
<script th:inline="javascript">

$(document).ready(function(){

	$("#form_adPositionEdit").validate({
	    rules:{
	    	adPositionName:{  //广告位名称长度不能超过 200个字符
	            required:true,
	            maxlength:200
	        },
	        adPositionSymbol:{  
	        	required:true,
	        	 
	        },
	        belongPage:{    
	        	required:true, 
	        },
	        adPositionWidth:{ 
	        	min:1,
	        	required:true, 
	        	digits:true,
	           
	        },
	        adPositionHeight:{
	        	min:1,
	        	required:true, 
	        	digits:true,
	        }
	    },
	    messages:{
	    	adPositionName:{
	            required:"请输广告位名称",
	            maxlength:"最大不能超过200个字符"
	        },
	        adPositionSymbol:{
	            required:"请输入广告位唯一标识符",
	           
	        },
	        belongPage:{
	            required:"请输入广告位所属页面",
	            
	        },
	       
	        adPositionWidth:{
	        	required:"请输入广告位宽度",
	        },
	        adPositionHeight:{
	        	required:"请输入广告位高度",
	        }

	    }
	});

	})
	
function check(){
	//	alert($("#adPositionSymbol").val());
	//alert($('#adPositionId').val());   id:$('#adPositionId').val(),
	
	if($('#adPositionId').val()){
		id = $('#adPositionId').val();
	}else{
		id = 0;
	}
	//if(id){
		$.ajax({
			url:'/advertisement/adPosition/check',
			data:{id: id,inputContent:$("#adPositionSymbol").val()},
			method:'post',
			success:function(data){
				if(data){
					alert('该广告位唯一标识符已经存在，请重新填写！');
					$("#adPositionSymbol").val("");
					return false;
				}			
			}
		});
	//}
}

</script>
	<div class="row">
		<div class="col-md-12">
			<div class="btn-group pull-right">
				<a href="index.html" th:href="@{/advertisement/adPosition/index/}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
			</div>
		</div>
	</div>
	 
	<div class="row">
		<div class="col-md-12">
			<div class="form">
				<form role="form" id="form_adPositionEdit"  th:action="@{/advertisement/adPosition/save}" th:object="${adPositionInfo}" method="post" class="form-horizontal">
					<h4 class="form-section">广告位基本信息管理</h4>
					<input type="hidden" id="adPositionId" th:field="*{id}" />
					<div class="form-body">
						
						<div class="form-group" th:class="${#fields.hasErrors('adPositionName')}? 'form-group has-error' : 'form-group'">
							<label class="control-label col-md-3">广告位名称<span class="required" aria-required="true">* </span></label>							
							<div class="col-md-4">
								<input type="text" class="form-control"  id="adPositionName" name="adPositionName" placeholder="广告位名称" th:field="*{adPositionName}"/>
								<span class="help-block" th:if="${#fields.hasErrors('adPositionName')}" th:errors="*{adPositionName}">广告位名称不能为空</span>
							</div>
						</div>			
						
						<div class="form-group" th:class="${#fields.hasErrors('adPositionSymbol')}? 'form-group has-error' : 'form-group'">
							<label class="control-label col-md-3">广告位唯一标识符<span class="required" aria-required="true">* </span></label>
							<div class="col-md-4">
								<input type="text" onBlur="check();"  id="adPositionSymbol" name="adPositionSymbol" class="form-control" placeholder="广告位唯一标识符" th:field="*{adPositionSymbol}" />
								<span class="help-block" th:if="${#fields.hasErrors('adPositionSymbol')}" th:errors="*{adPositionSymbol}">广告位唯一标识符不能为空</span>
							</div>
						</div>					
						
						<div class="form-group" th:class="${#fields.hasErrors('belongPage')}? 'form-group has-error' : 'form-group'" >
				 			<label class="control-label col-md-3" for="belongPage">广告位所属页面 <span class="required" aria-required="true">* </span></label>	
				 			<div class="col-md-4">
					 			<select th:field="*{belongPage}" name = "belongPage" id="belongPage" style="width:150px;"  th:remove="none" class="form-control">
					                	<option value="">所属页面</option>
					                	<option value="INDEXPAGE">首页</option>
					                	<option value="CATEGORYPAGE">分类页</option>
					                	<option value="SEARCHPAGE">搜索页</option>
					                	<option value="DETAILSPAGE">详情页</option>
					                	<option value="TOPICPAGE">专题页</option>
					            </select>
				            </div>
				 		</div>		
						
						<div class="form-group" th:class="${#fields.hasErrors('adPositionWidth')}? 'form-group has-error' : 'form-group'">
							<label class="control-label col-md-3">广告位宽度<span class="required" aria-required="true">* </span></label>
							<div class="col-md-4">
								<input type="text"   id="adPositionWidth" name="adPositionWidth" class="form-control" placeholder="广告位宽度" th:field="*{adPositionWidth}" />
								<span class="help-block" th:if="${#fields.hasErrors('adPositionWidth')}" th:errors="*{adPositionWidth}">广告位宽度不能为空</span>
							</div>
						</div>
						
						<div class="form-group" th:class="${#fields.hasErrors('adPositionHeight')}? 'form-group has-error' : 'form-group'">
							<label class="control-label col-md-3">广告位高度<span class="required" aria-required="true">* </span></label>
							<div class="col-md-4">
								<input type="text"   id="adPositionHeight" name="adPositionHeight" class="form-control" placeholder="广告位高度" th:field="*{adPositionHeight}" />
								<span class="help-block" th:if="${#fields.hasErrors('adPositionHeight')}" th:errors="*{adPositionHeight}">广告位宽度不能为空</span>
							</div>
						</div>
						
						<div class="form-group">
							<label class="control-label col-md-3">广告位描述 <span class="required" aria-required="true"></span></label>
							<div class="col-md-4">
								<input type="text" class="form-control" name="Description" id="Description" placeholder=" " th:field="*{Description}" />
								<span class="help-block"></span>
							</div>
						</div>
					
						 
						
					</div>
						
					<div class="form-actions fluid">
						<div class="col-md-offset-3 col-md-9">
							<button type="submit" name="btn_submit" id="btn_submit" class="btn blue">提交</button>
							
 						</div>
					</div>
				</form>		
			</div>
		</div>
	</div>
</div>	
 
</body>
</html>